package dissertation.extensions.beans.base.view;

import com.intellij.ui.DocumentAdapter;
import static dissertation.common.constants.Constants.*;

import javax.swing.*;
import java.awt.*;

public class CreateEJBPanel extends JPanel {
    private JTextField jTextFieldEJBName;
    private JTextField jTextFieldEJBClass;

    public CreateEJBPanel(DocumentAdapter documentAdapter, String ejbNameSuffix, String ejbClassNameSuffix) {
        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

        JPanel jPanelFirstRow = new JPanel();
        JLabel jLabelEJBName = new JLabel(EJB_NAME_LABEL);
        jLabelEJBName.setPreferredSize(new Dimension(80, 20));
        jPanelFirstRow.add(jLabelEJBName);
        jTextFieldEJBName = new JTextField();
        jTextFieldEJBName.setPreferredSize(new Dimension(150, 20));

        jTextFieldEJBName.getDocument().addDocumentListener(documentAdapter);

        jPanelFirstRow.add(jTextFieldEJBName);
        JLabel ejbNameSuffixLabel = new JLabel(ejbNameSuffix);
        ejbNameSuffixLabel.setPreferredSize(new Dimension(50, 20));
        jPanelFirstRow.add(ejbNameSuffixLabel);
        add(jPanelFirstRow);

        JPanel jPanelSecondRow = new JPanel();
        JLabel jLabelEJBClass = new JLabel(EJB_CLASS_LABEL);
        jLabelEJBClass.setPreferredSize(new Dimension(80, 20));
        jPanelSecondRow.add(jLabelEJBClass);
        jTextFieldEJBClass = new JTextField();
        jTextFieldEJBClass.setPreferredSize(new Dimension(150, 20));
        jPanelSecondRow.add(jTextFieldEJBClass);
        JLabel ejbClassSuffixLabel = new JLabel(ejbClassNameSuffix);
        ejbClassSuffixLabel.setPreferredSize(new Dimension(50, 20));
        jPanelSecondRow.add(ejbClassSuffixLabel);
        add(jPanelSecondRow);
    }

    public JTextField getjTextFieldEJBName() {
        return jTextFieldEJBName;
    }

    public JTextField getjTextFieldEJBClass() {
        return jTextFieldEJBClass;
    }
}
